/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2012
 */

package com.tech15.pub.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.tech15.core.dao.SysUserDao;
import com.tech15.core.model.SysUser;
import com.tech15.pub.model.*;
import com.tech15.pub.dao.*;
import com.tech15.pub.service.*;
import com.tech15.pub.vo.query.*;

/**
 * @author 胡作正 email:zuozhenghu@sina.com
 * @version 1.0
 * @since 1.0
 */

@Service
@Transactional
public class EmployeeDemandManager extends BaseManager<EmployeeDemand,Long>{

	private EmployeeDemandDao employeeDemandDao;
	private SysUserDao sysUserDao;
	private PubDataDao pubDataDao;
	
	public void setPubDataDao(PubDataDao dao) {
		this.pubDataDao = dao;
	}
	
	public void setSysUserDao(SysUserDao dao) {
		this.sysUserDao = dao;
	}
	public void setEmployeeDemandDao(EmployeeDemandDao dao) {
		this.employeeDemandDao = dao;
	}
	public EntityDao getEntityDao() {
		return this.employeeDemandDao;
	}
	
	@Transactional(readOnly=true)
	public Page findPage(EmployeeDemandQuery query) {
		return employeeDemandDao.findPage(query);
	}
	
	@Transactional(readOnly=true)
	public Page findByPageRequest(PageRequest pr) {
		return employeeDemandDao.findByPageRequest(pr);
	}
	
	public EmployeeDemand getById(Long id){
		EmployeeDemand ed = employeeDemandDao.getById(id);
		if(ObjectUtils.isNotEmpty(ed.getYgid())){
			SysUser user = sysUserDao.getById(ed.getYgid());
			ed.setUsername(user.getUsername());
		}
		if(ObjectUtils.isNotEmpty(ed.getLb())){
			PubData pd = pubDataDao.getById(ed.getLb());
			ed.setDataname(pd.getName());
		}
		return ed;
	}
	
}
